unit adaptors;
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
interface
uses Bass, SysUtils;
procedure ENGINE_FREE;
function Create_channel(const filename: string; const faked: boolean): Hstream;
procedure Terminate_Channel(const hndl: Hstream);
function Get_length(const hndl: Hstream): Float;
implementation

function Create_channel(const filename: string; const faked: boolean): Hstream;
var
  hndl: Hstream;
begin
  hndl := Bass_StreamCreateFile(False, pchar(filename), 0, 0, BASS_ATTRIB_VOL);
  if (not faked) and( hndl <> 0) then
    BAss_channelPlay(hndl, false);
  Create_Channel := hndl;
end;

procedure ENGINE_FREE;
begin
  bass_Free;
end;

procedure Terminate_Channel(const hndl: Hstream);
begin
  BAss_StreamFree(hndl);
end;

function Get_Length(const hndl: Hstream): Float;
var
  curlen: Cardinal;
  //curlen: Float;
begin
  curlen := Bass_Channelgetlength(hndl, BASS_POS_BYTE);
  Get_Length := BASS_ChannelBytes2Seconds(hndl, curlen);
end;

end.
